package com.hq.door.interceptor;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.http.MediaType;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import com.hq.door.util.staticErrorCode;

public class StudentFrontInterceptor extends HandlerInterceptorAdapter {

	@Override
	public boolean preHandle(HttpServletRequest request,
			HttpServletResponse response, Object handler) throws Exception {
			if(request.getSession().getAttribute("loginUser")==null){
				response.setContentType(MediaType.APPLICATION_JSON_UTF8_VALUE);
				PrintWriter pw = response.getWriter();
				pw.write(staticErrorCode.error_code_no_login);
				pw.flush();
				pw.close();
				return false;
			}
		return super.preHandle(request, response, handler);
	}

}
